#include "StdAfx.h"
#include "QuoteSocket.h"

void CQuoteSocket::OnClose( int nErrorCode )
{
	m_bConnected = false;
	switch( nErrorCode )
	{
	case 0:
		{
			PostStateSockMsg( ISockMsg::SS_CLOSED, m_addrRemote );
			break;
		}
	default:
		{
			PostStateSockMsg( ISockMsg::SS_CLOSED, m_addrRemote );
			break;
		}
	}

	CAsyncSocket::OnClose(nErrorCode);
}

bool CQuoteSocket::Create( USHORT uPort )
{
	PostStateSockMsg( ISockMsg::SS_CREATING );
	if( !CAsyncSocket::Create( uPort ) )
	{
		PostFailedSockMsg( ISockMsg::SA_CREATE );
		return false;
	}
	PostStateSockMsg( ISockMsg::SS_CREATED );

	return true;
}


bool CQuoteSocket::Create( void )
{
	PostStateSockMsg( ISockMsg::SS_CREATING );
	if( !CAsyncSocket::Create() )
	{
		PostFailedSockMsg( ISockMsg::SA_CREATE );
		return false;
	}
	PostStateSockMsg( ISockMsg::SS_CREATED );

	return true;
}
// 
// bool CQuoteSocket::Create( void )
// {
// 	PostStateSockMsg( ISockMsg::SS_CREATING );
// 	SOCKET skt = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
// 	if( INVALID_SOCKET == skt )
// 	{
// 		PostFailedSockMsg( ISockMsg::SA_CREATE );
// 		return false;
// 	}
// 
// 	m_hSocket= skt;
// 	PostStateSockMsg( ISockMsg::SS_CREATED );
// 	return true;
// }
void CQuoteSocket::Close( void )
{
	CAsyncSocket::Close();
	PostStateSockMsg( ISockMsg::SS_CLOSED );
}

